/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package wollongongtemp.web;

import java.util.List;
import javax.ejb.EJB;
import javax.el.ELContext;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import wollongongtemp.ejb.CustomerBean;

/**
 *
 * @author Wade
 */
@ManagedBean(name = "listCustomerView")
@RequestScoped
public class ListCustomerView {
    @EJB
    private CustomerBean customerBean;

    /** Creates a new instance of ListCustomerView */
    public ListCustomerView() {
    }

    public List getCustomerList() {
        return customerBean.getCustomerList();
    }

    public String editCustomer() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ELContext elContext = facesContext.getELContext();

        int customerId = Integer.parseInt((String)facesContext.getExternalContext().getRequestParameterMap().get("id"));
        EditCustomerView editCustomerView  = (EditCustomerView) facesContext.getApplication().getELResolver().getValue(elContext, null, "editCustomerView");
        editCustomerView.setId(customerId);
        
        return "/editCustomer.xhtml";
    }

}
